<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateFilesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('files', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('type')->index('type_index')->comment('文件类型');
			$table->string('path')->comment('文件路径');
			$table->char('mime_type', 30)->comment('文件mimeType');
			$table->char('md5', 32)->comment('Md5');
			$table->string('title', 100)->comment('文件标题');
			$table->char('folder', 20)->index('folder_index')->comment('文件对象类型');
			$table->string('object_id', 64)->index('object_id_index')->comment('文件对象ID');
			$table->integer('size')->default(0)->comment('文件大小');
			$table->smallInteger('width')->default(0)->comment('宽度');
			$table->smallInteger('height')->default(0)->comment('高度');
			$table->integer('downloads')->default(0)->comment('下载次数');
			$table->string('public')->default('1')->comment('是否公开');
			$table->string('editor')->default('0')->comment('富编辑器图片');
			$table->string('status')->default('0')->comment('附件状态');
			$table->integer('created_op')->default(0)->comment('创建人');
			$table->timestamps();
			$table->unique(['md5','type','folder'], 'md5_type_folder_unique');
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('files');
	}

}
